<template>
  <div class="contract-history">
    <a-card title="审核历史">
      <s-table
        bordered
        size="middle"
        :row-key="(record) => record.history_id"
        :columns="checkColumns"
        :data="checkData"
      >
        <template slot="check_result" slot-scope="text">
          <a-tag color="red">{{ text }}</a-tag>
        </template>
      </s-table>
    </a-card>
  </div>
</template>

<script>
  import { STable } from '@/components'
  import { history } from '@/api/contract'
  import contractColumns from '@/columns/contract'
  const checkColumns = contractColumns.check
  export default {
    components: {
      STable
    },
    name: 'Histories',
    props: {
      query: {
        type: Object,
        default: () => {}
      }
    },
    data () {
      return {
        checkColumns,
        checkData: parameters => {
          return history(Object.assign(parameters, this.queryParam)).then(res => {
            return res.result
          })
        },
        queryParam: {}
      }
    },
    created () {
      this.init()
    },
    methods: {
      init () {
        const params = {}
        params['filter[contract_id]'] = this.query['contract_id']
        this.queryParam = params
      }
    }
  }
</script>

<style scoped>

</style>
